Sorting algorithms rearrange arrays. Stable sorting algorithms do not permute equal entries.
Info
Example: If you have two columns (name and gpa) and the “key” is the GPA. You want to sort by GPA but when you have equal GPA values you want to keep the names in alphabetical order (they are currently in alphabetical order). You would want a stable sorting algorithm for this use case.
Partition (why is it not stable?)
Example
Input Array:
Partition code:
Notice the 4 at the end was initially at the beginning of the array